package mate.dart;

public class ThrowEvent {
	private String result;
	private boolean allDarts;


	public ThrowEvent(String result) {
		this(result, false);
	}
	
	public ThrowEvent(String result, boolean allInOne) {
 		this.allDarts = allInOne;
		if (result.contains("x")) {
			this.result = result;
		} else {
			this.result = result + "x1";
		}
	}

	public String getResult() {
		return result;
	}
	
	public int getNum() {
		return Integer.parseInt(result.split("x")[0]); 
	}
	
	public int getCount() {
		return Integer.parseInt(result.split("x")[1]);
	}
	
	public int getPointsCount() {
		return getNum() * getCount();
	}
	
	public boolean isDouble() {
		if (allDarts) {
			return true;
		} else {
			String[] s = result.split("x");
			return Integer.parseInt(s[1]) == 2;
		}
	}
	
	public boolean isAllDarts() {
		return allDarts;
	}

	@Override
	public String toString() {
		return "Result: " + result + ", allInOne: " + allDarts;
	}
}
